package org.raymond.iworks.study.basic.designpattern.iterator;

import java.util.Iterator;
import java.util.List;

/**
 * @author raymond
 * @version V1.0
 * @Description: TODO
 */
public class OutputImpl {
    List<College> collegeList;

    public OutputImpl(List<College> collegeList) {
        this.collegeList = collegeList;
    }

    public void printCollege(){
        Iterator<College> it = collegeList.iterator();
        while (it.hasNext()){
            College college = it.next();
            System.out.println("==="+college.name()+"===");
            printDepartment(college.createIterator());
        }
    }

    public void printDepartment(Iterator it){
        while(it.hasNext()){
            Department department = (Department) it.next();
            System.out.println(department.getName());
        }
    }
}
